package game.border;

import be.kuleuven.cs.som.annotate.Basic;
import be.kuleuven.cs.som.annotate.Raw;

/**
 * A class involving a door.
 * 
 * @invar		| this.isMadeOfSlipperyMaterial == false
 * 
 * @version     1.0
 * @author      Dries Liebens 
 *   			Loic Vercruysse
 */
public class WallWithDoor extends Wall{

	/**
	 * Initialize this new WallWithDoor with the door closed.
	 * 
	 *  @effect	| this(false)
	 */
	public WallWithDoor() {
		this(false);
	}
	
	/**
	 * Initialize this new WallWithDoor with the door is given stand.
	 * 
	 * @param	doorIsOpen
	 * 			If the door is open.
	 * @post	| new.isDoorOpen() == doorIsOpen
	 * @post	| new.isMadeOfSlipperyMaterial() == false
	 */
	public WallWithDoor(boolean doorIsOpen) {
		super(false);
		setDoorIsOpen(doorIsOpen);
	}
	
	/**
	 * Returns whether the door in the wall is open.
	 */
	@Basic @Raw
	public boolean isDoorOpen() {
		return doorIsOpen;
	}
	
	/**
	 * Sets if the door is open.
	 * 
	 * @param	doorIsOpen
	 * 			If the door is open.
	 * @post	| new.isDoorOpen() == doorIsOpen
	 */
	public void setDoorIsOpen(boolean doorIsOpen) {
		this.doorIsOpen = doorIsOpen;
	}
	
	/**
	 * Opens the door if the door was closed.
	 * 
	 * @effect	| setDoorIsOpen(true)
	 */
	public void openDoor() {
		setDoorIsOpen(true);
	}
	
	/**
	 * Closes the door if the door was opened.
	 * 
	 * @effect	| setDoorIsOpen(false)
	 */
	public void closeDoor() {
		setDoorIsOpen(false);
	}
	
	/**
	 * Variable referencing if the door is open of this wallWithDoor.
	 */
	private boolean doorIsOpen;
	
	/**
	 * Checks whether given obstacle is instance of the class WallWithDoor.
	 * 
	 * @param	obstacle
	 * 			Obstacle to check.
	 * @return	| if(obstacle == null)
	 * 			|	result = false
	 * @return	| result = (obstacle.getClass() == WallWithDoor.class)
	 */
	@Raw
	public static boolean isWallWithDoor(Obstacle obstacle) {
		if(obstacle == null)
			return false;
		return (obstacle.getClass() == WallWithDoor.class);
	}
	
	/**
	 * Makes a copy of this wallWithDoor.
	 * 
	 * @return	| new WallWithDoor(isDoorOpen())
	 */
	@Override
	public WallWithDoor clone() {
		return new WallWithDoor(isDoorOpen());
	}
	
	/**
	 * Returns the closeness of WallWithDoor.
	 * 
	 * @return	| if(!isDoorOpen())
	 * 			|	result = 31;
	 * 			| else
	 * 			| 	result = 30
	 */
	@Override @Raw
	public int getCloseness() {
		if(!isDoorOpen())
			return 31;
		return 30;
	}
}
